package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.wms.domain.WmsOrder;
import com.ruoyi.wms.dto.WmsOrderDto;
import com.ruoyi.wms.service.IWmsOrderService;
import com.ruoyi.wms.vo.WmsOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * WMS订单Controller
 *
 * @author ruoyi
 * @date 2025-09-12
 */

@Api(value = "WMS订单Controller", tags = "WMS订单Controller")
@RestController
@RequestMapping("/order")
public class WmsOrderController extends BaseController {
    @Autowired
    private IWmsOrderService wmsOrderService;

    /**
     * 查询WMS订单列表
     */
//    @RequiresPermissions("lvlian:order:list")
    @GetMapping("/list")
    public TableDataInfo list(WmsOrderDto wmsOrder) {
        startPage();
        List<WmsOrderVo> list = wmsOrderService.selectWmsOrderList(wmsOrder);
        return getDataTable(list);
    }



    /**
     * 获取WMS订单详细信息
     */
//    @RequiresPermissions("lvlian:order:query")
  /*  @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(wmsOrderService.selectWmsOrderById(id));
    }*/



    @ApiOperation("获取司机信息详细信息息getInfoById")
    @GetMapping("/getInfoById")
    public AjaxResult getInfoById(@ApiParam(value = "司机信息详细信息id", required = true) @RequestParam(value = "id") String id) {
        return success(wmsOrderService.selectWmsOrderById(id));
    }


    /**
     * 修改WMS订单
     */
    @RequiresPermissions("lvlian:order:edit")
    @Log(title = "WMS订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsOrderVo wmsOrder) {
        try {
            return toAjax(wmsOrderService.updateWmsOrder(wmsOrder));
        }catch (Exception e){
            e.printStackTrace();
            return error("保存错误,填入值异常");
        }


    }

    /**
     * 删除WMS订单
     */
    @Log(title = "WMS订单", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        return toAjax(wmsOrderService.deleteWmsOrderByIds(ids));
    }
}
